/*
 * PayOutView.java
 *
 * Created on August 25, 2006, 8:15 PM
 */
package com.floreantpos.ui.views;

import com.floreantpos.main.Application;
import com.floreantpos.swing.TransparentPanel;
import com.floreantpos.ui.dialog.NotesDialog;
import java.awt.Color;

/**
 *
 * @author MShahriar
 */
public class PayOutView extends TransparentPanel {

  /**
   * Creates new form PayOutView
   */
  public PayOutView() {
    initComponents();
    numberSelectionView.setDecimalAllowed(true);
  }

  public void initialize() {

  }

  private void initComponents() {

    numberSelectionView = new com.floreantpos.ui.views.NumberSelectionView();
    jLabel3 = new javax.swing.JLabel();
    btnAddNote = new com.floreantpos.swing.PosButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    tfNote = new javax.swing.JTextArea();

    numberSelectionView.setTitle(com.floreantpos.POSConstants.AMOUNT);

    jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
    jLabel3.setText(com.floreantpos.POSConstants.OBSERVATIONS);

    btnAddNote.setText("...");
    btnAddNote.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        btnAddNoteActionPerformed(evt);
      }
    });

    tfNote.setEditable(false);
    tfNote.setColumns(20);
    tfNote.setLineWrap(true);
    tfNote.setRows(5);
    tfNote.setWrapStyleWord(true);
    tfNote.setBackground(Color.WHITE);
    jScrollPane1.setViewportView(tfNote);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(numberSelectionView, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                    .add(7, 7, 7)
                                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 363, Short.MAX_VALUE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(btnAddNote, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 56, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap())
                            .add(layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 90, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
    );
    layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(numberSelectionView, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 347, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(12, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(jLabel3)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(btnAddNote, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 300, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(19, 19, 19))
    );
  }

  private void btnAddNoteActionPerformed(java.awt.event.ActionEvent evt) {
    NotesDialog dialog = new NotesDialog(Application.getPosWindow(), true);
    dialog.setTitle(com.floreantpos.POSConstants.ENTER_PAYOUT_NOTE);
    dialog.pack();

    if (tfNote.getText().length() > 0) {
      dialog.setNote(tfNote.getText());
    }

    dialog.open();

    if (!dialog.isCanceled()) {
      tfNote.setText(dialog.getNote());
    }
  }

  private com.floreantpos.swing.PosButton btnAddNote;
  private javax.swing.JLabel jLabel3;
  private javax.swing.JScrollPane jScrollPane1;
  private com.floreantpos.ui.views.NumberSelectionView numberSelectionView;
  private javax.swing.JTextArea tfNote;

  public double getPayoutAmount() {
    return numberSelectionView.getValue();
  }

  public String getNote() {
    return tfNote.getText();
  }
}
